package com.wealth.scsj.b_app.view.fragment.fourmodel;


import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.gigamole.navigationtabstrip.NavigationTabStrip;
import com.wealth.scsj.b_app.R;
import com.wealth.scsj.b_app.adapter.FragmentAdapter;
import com.wealth.scsj.b_app.view.fragment.basemodel.BaseFragment;
import com.wealth.scsj.b_app.view.fragment.threestatemodel.FinishedFragment;
import com.wealth.scsj.b_app.view.fragment.threestatemodel.IngFragment;
import com.wealth.scsj.b_app.view.fragment.threestatemodel.RefundFragment;
import com.wealth.scsj.b_app.view.fragment.waitmodel.NewOrderFragment;
import com.wealth.scsj.b_app.view.fragment.waitmodel.NewRefundFragment;

import java.util.ArrayList;


/**
 * 订单管理
 */
public class OrderFragment extends BaseFragment {

    private String[] titles = {"新订单", "待退款"};
    private NavigationTabStrip tabStrip;
    private ViewPager mViewPager;
    private FragmentAdapter mainFragmentAdapter;
    private TextView mTvTopTittle;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View inflate = inflater.inflate(R.layout.fragment_order, null);
        initView(inflate, null);
        initData();
        return inflate;
    }

    @Override
    protected void initView(View view, Bundle savedInstanceState) {
        intiNavigationBar(view);
        mTvTopTittle =view.findViewById(R.id.tv_top_tittle);
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {
        mTvTopTittle.setText("待处理");
    }

    @Override
    protected int getLayoutId() {
        return 0;
    }

    private void intiNavigationBar(View view) {

        //顶部指示器
        tabStrip = view.findViewById(R.id.mediator_tab);
        mViewPager = view.findViewById(R.id.viewpager);
        mViewPager.setOffscreenPageLimit(2);
        ArrayList<BaseFragment> list = new ArrayList<>();

        NewOrderFragment newOrderFragment = new NewOrderFragment();
        NewRefundFragment newRefundFragment = new NewRefundFragment();

        list.add(newOrderFragment);
        list.add(newRefundFragment);

        mainFragmentAdapter = new FragmentAdapter(getHoldingActivity().getSupportFragmentManager(), list);
        mViewPager.setAdapter(mainFragmentAdapter);
        tabStrip.setViewPager(mViewPager, 0);
        tabStrip.setTitles(titles);
        tabStrip.setStripType(NavigationTabStrip.StripType.LINE);
        tabStrip.setStripGravity(NavigationTabStrip.StripGravity.BOTTOM);
        tabStrip.setTabIndex(0, true);
    }

}
